package com.mengya.adapter;

import com.mengya.gzcwt.R;
import com.mengya.gzcwt.R.drawable;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
	private Context mContext;
	private Integer[] mImageIds = { R.drawable.home_icon0, R.drawable.icon2_1,
			R.drawable.icon3_1, R.drawable.icon4_1, R.drawable.icon5_1,R.drawable.icon6_1,  };

	public ImageAdapter(Context c) {
		mContext = c;
	}

	public int getCount() {
		return mImageIds.length;
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(mContext);
			// imageView.setLayoutParams(new
			// GridView.LayoutParams(LayoutParams.WRAP_CONTENT,
			// LayoutParams.WRAP_CONTENT));
			imageView.setLayoutParams(new GridView.LayoutParams(110, 110));
			imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
		} else {
			imageView = (ImageView) convertView;
		}
		// imageView.setImageResource(mImageIds[position]);
		imageView.setBackgroundResource(mImageIds[position]);
		return imageView;
	}

}